package com.cndongtai.util;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileUtil {
	
	public static boolean saveFile(String filePath, byte[] content) throws IOException {
		boolean result = true;
		BufferedOutputStream bos = null;
		try {
			File file = new File(filePath);
			if (!file.getParentFile().exists()) {
				file.getParentFile().mkdirs();
			}
			file.createNewFile();
			bos = new BufferedOutputStream(new FileOutputStream(file));
			bos.write(content);
		} catch (FileNotFoundException e) {
			result = false;
			throw new FileNotFoundException();
		} finally {
			if (null != bos) {
				bos.close();
			}
		}
		
		return result;
	}
}
